//
//  MoreWorkmateCell.m
//  MyProject
//
//  Created by 石小强 on 2018/3/23.
//  Copyright © 2018年 yanjiaming. All rights reserved.
//

#import "MoreWorkmateCell.h"

@implementation MoreWorkmateCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.headerIV.layer.cornerRadius = 35.5;
    self.headerIV.layer.masksToBounds = YES;
}

- (void)setModel:(WorkmateModel *)model {
    _model = model;
    
    [self.headerIV sd_setImageWithURL:ImageURLWithKey(model.headImg) placeholderImage:PlaceholderImage];
    self.nameL.text = model.nickName;
    self.tagIV.hidden = model.hasAssurePassService ? NO : YES;
    self.positionL.text = model.positionName;
    self.yearNumL.text = [NSString stringWithFormat:@"已在职%@年 | 帮助过%@人", model.inServiceTime, model.helpedCount];
    self.scoreL.text = [NSString stringWithFormat:@"%.0f%@", [model.degreeOfSatisfaction floatValue]*100,@"%"];
    
    
    CAShapeLayer *layerBack = [[CAShapeLayer alloc]init];
    layerBack.lineWidth = 4;
    //圆环的颜色
    layerBack.strokeColor = UIColorFromRGB(0xE2F2F4).CGColor;
    //背景填充色
    layerBack.fillColor = [UIColor clearColor].CGColor;
    //设置半径为10
    CGFloat radius = 22;
    //按照顺时针方向
    BOOL clockWise = true;
    //初始化一个路径
    UIBezierPath *pathBack = [UIBezierPath bezierPathWithArcCenter:CGPointMake(22, 22) radius:radius startAngle:0 endAngle:2*M_PI clockwise:clockWise];
    layerBack.path = [pathBack CGPath];
    [self.scoreV.layer addSublayer:layerBack];
    
    
    CAShapeLayer *layer = [CAShapeLayer new];
    layer.lineWidth = 4;
    //圆环的颜色
    layer.strokeColor = UIColorFromRGB(0x42CDD9).CGColor;
    //背景填充色
    layer.fillColor = [UIColor clearColor].CGColor;
    //设置半径为10
    
    //初始化一个路径
    UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(22 , 22 ) radius:radius startAngle:3*M_PI_2 endAngle:([model.degreeOfSatisfaction floatValue]*2*M_PI+3*M_PI_2) clockwise:clockWise];
    layer.path = [path CGPath];
    [self.scoreV.layer addSublayer:layer];
}

@end
